//
//  ArtTimeView.m
//  EasyToo
//
//  Created by Jr Lan on 13-9-2.
//
//

#import "ArtTimeView.h"

@implementation ArtTimeView
{
    id<artTimeViewDelegate> _timedelegate;
}

- (id)initWithFrame:(CGRect)frame andDelegate:(id<artTimeViewDelegate>)timedelegate
{
    _timedelegate = timedelegate;
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        // 设置tableView的数据源
        self.dataSource = self;
        // 设置tableView的委托
        self.delegate = self;
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: nil];
    
    //加载图像
    UIImageView *imgview  = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"0.jpg"]]autorelease];
    imgview.frame = CGRectMake(10, 10, 70, 80);
    [cell.contentView addSubview:imgview];
    
    //加载名字
    UILabel *namelbl = [[[UILabel alloc]initWithFrame:CGRectMake(100, 10, 150, 20)]autorelease];
    namelbl.text = @"周杰伦2013广州演唱会";
    namelbl.font = [UIFont systemFontOfSize:15];
    namelbl.adjustsFontSizeToFitWidth = YES;
    [cell.contentView addSubview:namelbl];
    
    //加载地点
    UILabel *addresslbl = [[[UILabel alloc]initWithFrame:CGRectMake(100, 30, 150, 20)]autorelease];
    addresslbl.text = @"广东省广州市";
    addresslbl.font = [UIFont systemFontOfSize:10];
    addresslbl.textColor = [UIColor lightGrayColor];
    [cell.contentView addSubview:addresslbl];
    
    //加载场馆
    UILabel *gemlbl = [[[UILabel alloc]initWithFrame:CGRectMake(100, 50, 150, 20)]autorelease];
    gemlbl.text = @"天河体育馆";
    gemlbl.font = [UIFont systemFontOfSize:10];
    gemlbl.textColor = [UIColor lightGrayColor];
    [cell.contentView addSubview:gemlbl];
    
    //加载时间
    UILabel *timelbl = [[[UILabel alloc]initWithFrame:CGRectMake(100, 70, 150, 20)]autorelease];
    timelbl.text = @"2013.12.12";
    timelbl.font = [UIFont systemFontOfSize:10];
    timelbl.textColor = [UIColor lightGrayColor];
    [cell.contentView addSubview:timelbl];
    
    //加载价格
    UILabel *pricelbl = [[[UILabel alloc]initWithFrame:CGRectMake(260, 50, 50, 40)]autorelease];
    pricelbl.text = @"￥50";
    pricelbl.font = [UIFont systemFontOfSize:20];
    pricelbl.textColor = [UIColor redColor];
    pricelbl.adjustsFontSizeToFitWidth = YES;
    [cell.contentView addSubview:pricelbl];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 100;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_timedelegate clickArtTimeView:indexPath.row];
}

@end
